package com.tarena.lbs.stock.web.repository;

import com.tarena.lbs.pojo.stock.dos.CouponStockDO;
import com.tarena.lbs.stock.web.mapper.StockMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;
import java.util.List;

@Repository
public class StockRepository {
    @Autowired
    private StockMapper stockMapper;


    public boolean updateCouponNum(Integer couponId) {
        int rows=stockMapper.updateCouponNumById(couponId);
        return rows>0;
    }

    public List<CouponStockDO> getCouponNum(List<Integer> ids) {
        List<CouponStockDO> dos = new ArrayList<>();
        for (Integer couponId : ids) {
            CouponStockDO cDo = stockMapper.selectStockByCouponId(couponId);
            dos.add(cDo);
        }
        return dos;
    }
}
